package example.双指针;

// https://leetcode-cn.com/problems/is-subsequence/
public class Demo1 {
    // 判断 s 是否为 t 的子序列。
    public static boolean isSubsequence(String s, String t) {
        if (s.length() > t.length()) {
            return false;
        }
        int i = t.indexOf(s.charAt(0));
        return isTrue(s, t, i);
    }

    /**
     * @param s
     * @param t
     * @return
     */
    public boolean isSubsequence2(String s, String t) {
        int n = s.length(), m = t.length();
        int i = 0, j = 0;
        //当s走完了，就说明s是t的字串
        while (i < n && j < m) {
            if (s.charAt(i) == t.charAt(j)) {
                i++;
            }
            j++;
        }
        return i == n;
    }

    //
    public static boolean isTrue(String s, String t, int charStartAt) {
        return false;
    }

    public static void main(String[] args) {

        System.out.println(isSubsequence("abc", "ahbgdc"));
    }
}
